﻿/**
 * 
 */

var actionlinks=new Array();
var ExRanderActlnk = new Array();
var sprites = new Array();
//var actionlinks={}; map ,key -value;
var AcceptSprite;

var intervalID;
var onloading =0;
var onFight =0;


window.requestAnimFrame = (function(){
    return  window.requestAnimationFrame       || 
            window.webkitRequestAnimationFrame || 
            window.mozRequestAnimationFrame    || 
            window.oRequestAnimationFrame      || 
            window.msRequestAnimationFrame     || 
            function(/* function */ callback, /* DOMElement */ element){
              window.setTimeout(callback, RANDER_SPEED);
            };
  })();


//在普通地图场景中的控制
function Start_map(){

	intervalID   =   setInterval( "Gamerun()",RANDER_SPEED); 
	//requestAnimationFrame(Gamerun);
	//Gamerun();
	RedrawScreen();
}


function AddExaction(action){
	ExRanderActlnk.push(action)
}
function Addaction(sprite,action){
	if (sprite ==null){
		actionlinks.push(action);
	}
}

function Gamerun(){

	if (ExRanderActlnk.length>0){
		ExRanderActlnk[0].act();
		if (ExRanderActlnk[0].State ==2) 
			ExRanderActlnk.shift();
		return;
	}
	
	if (onloading !=0) return;
	
	RanderJobLst_Backgournd= new Array();
	RanderJobLst_Backgournd0= new Array();
	RanderJobLst_Beyound= new Array();
	
	
	for (i=0;i<actionlinks.length;i++){
		actionlinks[i].act();
	}
	
	for (i=0;i<sprites.length;i++){
		sprites[i].act();
	}
	
	scroll(AcceptSprite);
	
	
	for (i=0;i<bgAudio.length;i++){
		bgAudio[i].sound3d(AcceptSprite.Stepx,AcceptSprite.Stepy);
	}
}


function AddSnario(funn,parr){
	Snario.push(funn + "(" + parr + ");");
}

function GoNextSnario(){
	if (Snario.length ==0) {OnSnario = false; return;}
	OnSnario = true;
	eval( Snario.shift());
}

////禁止混淆 Begin
//window['AddSnario'] = AddSnario; 
//window['GoNextSnario'] = GoNextSnario; 
//window['AcceptSprite'] = AcceptSprite; 
////禁止混淆 END
